package top.truism.user.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
public class UserBalanceController {

    @Resource
    private RestTemplate restTemplate;

    @PostMapping("/user/balance")
    public String decreaseBalance() {

        String url = "http://FUND/fund/balance/{userId}/{balanceAmount}";
        Map<String, Object> params = new HashMap<>();
        params.put("userId", "admin");
        params.put("balanceAmount", 1000);

        String resultMsg = restTemplate.postForObject(url, null, String.class, params);

        System.out.println(resultMsg);

        return "交易成功";

    }


}
